package www.controller.member;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.validation.BindException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;

import www.member.MemberMgr;
import www.member.ZipcodeDTO;

public class ZipcodeController extends SimpleFormController {
	private MemberMgr mgr;

	public void setMgr(MemberMgr mgr) {
		this.mgr = mgr;
	}

	@Override
	protected ModelAndView onSubmit(HttpServletRequest request,
			HttpServletResponse response, Object command, BindException errors)
			throws Exception {
		ModelAndView mv= new ModelAndView();
		
		ZipcodeDTO dto = (ZipcodeDTO) command;
		
		boolean flag = true;
		List list = mgr.zipcodeRead(dto.getArea3());
		if(list.isEmpty()){
			flag = false;
		}
		mv.addObject("flag",flag);
		mv.addObject("list",list);
		mv.addObject("area3",dto.getArea3());
		mv.setViewName(getSuccessView());
		return mv;
	}
	
	

}
